package net.wang.staffing_system.service;

import net.wang.staffing_system.utils.ExcelUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.Map;

/**
 *
 */
@Service
public class FileService {

    public Map<String, Object> saveExcel(MultipartFile file) throws IOException {
        File saveFile = new File("D:\\", file.getOriginalFilename());
        file.transferTo(saveFile);
        return ExcelUtils.excelToMap(saveFile);
    }

    public Map<String, Object> saveCSV(MultipartFile file) throws IOException {
        File saveFile = new File("D:\\", file.getOriginalFilename());
        file.transferTo(saveFile);
        return ExcelUtils.csvToJSON(saveFile);
    }


}
